<?php
namespace Addons\Keywords;
use Addons\Common\Controller\CommonController;

class Keywords extends CommonController{
    /**
     * @return string
     * 关键字内容的添加
     */
       public function keywordadd(array $contents=null){

           if(!is_null($contents)){
               if($data=M('keycontents')->find($contents['kid'])){
                   //编辑
                   if($contents['edit']){
                       $keycontents = M("keycontents");
                       $kid=$data['kid'];
                      return $keycontents->where("kid=$kid")->save($contents);
                   }
                   $this->assign('data',$data);
                   return $this->fetch("Addons/Keywords/View/keywordadd.html");
               }else{
                   $keycontents=M('keycontents');
                   $kcid=$keycontents->add($contents);
                   return $kcid;
               }
           }else{
               //没传参，表示读模板
               return $this->fetch("Addons/Keywords/View/keywordadd.html");
           }
       }

}